#include <iostream>
#include <thread>

using std::cout;
using std::endl;
using std::thread;

void threadFunc(int x)
{
    cout << endl << "void threadFunc(int)" << endl;
    cout << "child thread id = " << std::this_thread::get_id() << endl;
    cout << "x = " << x << endl;
}

int main(int argc, char *argv[])
{
    cout << "main thread id = " << std::this_thread::get_id() << endl;

    typedef void (&pFunc)(int);//定义函数引用类型的方式
    pFunc f = threadFunc;

    thread th(f, 3);//创建线程对象th
    cout << "child1 thread id = " << th.get_id() << endl;

    th.join();//让主线程等待子线程
    return 0;
}

